//
//  Emotion.swift
//  emojiKeyboardDemo
//
//  Created by Jin on 2018/5/17.
//  Copyright © 2018年 Jin. All rights reserved.
//

import UIKit

class Emotion : NSObject {
    //自定义属性
    @objc var code:String? {//emoji对用code
        didSet{
            guard let code = code else {
                return
            }
            
            //创建扫描器
            let scaner = Scanner(string: code)
            //扫描出code中的值
            var value:UInt32 = 0
            scaner.scanHexInt32(&value)
            //将value转成字符
            let c = Character(UnicodeScalar(value)!)
            //将字符转成字符串
            emojiCode = String(c)
        }
    }
    @objc var png:String?{ //普通表情对应的图片名称
        didSet{
            guard let png = png else {
                return
            }
            pngPath = Bundle.main.bundlePath + "/Emotions.bundle/" + png
        }
    }
    @objc var chs:String?  //普通表情对应的文字[简体中文] cht[繁体中文]
    //数据处理
    @objc var pngPath:String?
    @objc var emojiCode:String?
    var isRemove:Bool = false
    var isEmpty:Bool = false
    
    //自定义鼓构造函数
    init(dict:[String:String]){
        super.init()
        
        setValuesForKeys(dict)
    }
    
    init(isRemove:Bool) {
        self.isRemove = isRemove
    }
    
    init(isEmpty:Bool) {
        self.isEmpty = isEmpty
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {}
    
    override var description: String{
        return dictionaryWithValues(forKeys: ["emojiCode","pngPath","chs"]).description
     }
}
